package
{
	import BasicEngine.Dispatcher;
	import DataStore.BmpDataPool;
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.utils.ByteArray;
	import GameLogic.ENUM;
	import GameLogic.Game;
	import LoadUnit.LoadManager;
	import LoadUnit.UrlLoadTask;
	import Map.MapManager;
	import luaAlchemy.LuaAlchemy;
	
	[SWF(width = "760", height = "580", backgroundColor = "0xff33ff",frameRate = "60")]
	public class Robotlua extends Sprite
	{
		public function Robotlua()
		{
			Init();
			Game.Star();
			MapManager.Init();
			
			stage.addEventListener(MouseEvent.MOUSE_DOWN, function(e:Event):void
			{
				LoadManager.AddLoadTask("Resource/lua/temp.lua", ENUM.LOADLUATYPE, function(_st:String):void
				{
                    var luaAlchemyObj:LuaAlchemy = new LuaAlchemy();
                    luaAlchemyObj.setGlobal("this", this);
                    luaAlchemyObj.doString(_st);
                    
                    luaAlchemyObj.doString("DoCircle(3)");

					
					
				});
				
			});
			
			stage.addEventListener(MouseEvent.MOUSE_UP, function(e:Event):void
			{
				if (BmpDataPool.MapTiles > 10)
				{
					//var i:int = 0;
					//for (var j:int = 0; j < 50; j++)
					//{
						//var x:int = (j % 5);
						//var y:int = int(j / 5);
						//MapManager.PutTile(101, x, y);
					//}
					//for each(var item:BitmapData in BmpDataPool.MapPool)
					//{
						//var x:int = (i % 19) * 50;
						//var y:int = int(i / 19) * 50;
						//var img:Bitmap = new Bitmap(item);
						//img.x = x;
						//img.y = y;
						//addChild(img);
						//i++;
					//}
				}
			});
		}
		
		public function Init():void
		{
			Game.Init(this, 760, 580);
		}
	}
}